package org.ymjava.medical.wx.web;


import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.ymjava.medical.core.util.ResponseUtil;
import org.ymjava.medical.db.AllPackage.biz.MockExamBiz;
import org.ymjava.medical.db.AllPackage.biz.NurseQuestionBiz;
import org.ymjava.medical.db.AllPackage.entity.MockExam;
import org.ymjava.medical.db.AllPackage.entity.NurseQuestion;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/wx_answer/simulation")
public class SimulationController {

    private final Log logger = LogFactory.getLog(SimulationController.class);


    @Autowired
    MockExamBiz mockExamBiz;

    @Autowired
    NurseQuestionBiz nurseQuestionBiz;

    @GetMapping("/get_list")
    public Object get_list(Integer userId, Integer singleNum, Integer multipleNum, Integer judgeNum, Integer examId){


        //添加考场记录
        MockExam mockExam =  new MockExam();
        mockExam.setUserId(userId);
        mockExam.setAddTime(new Date());
        mockExam.setDeleted(0);
        mockExam.setJudgeNum(judgeNum);
        mockExam.setMultipleNum(multipleNum);
        mockExam.setSingleNum(singleNum);
        mockExamBiz.insert(mockExam);
        //查询抽题数组

        //单选题
        List<NurseQuestion> list_single = nurseQuestionBiz.query_mock_question(userId,singleNum,1);
        //多选题
        List<NurseQuestion> list_multiple = nurseQuestionBiz.query_mock_question(userId,multipleNum,2);
        //判断题
        List<NurseQuestion> list_judge = nurseQuestionBiz.query_mock_question(userId,multipleNum,3);

        list_single.addAll(list_multiple);
        list_single.addAll(list_judge);

        Map<String,Object> data  = new HashMap<>(1);
        data.put("list_question",list_single);

        return ResponseUtil.ok(data);
    }

}
